package com.shensi.api.admin.client.system;

import com.shensi.api.admin.client.fallback.system.SysRoleClientFallBack;
import com.shensi.common.core.constant.CloudConstant;
import com.shensi.common.core.domain.AjaxResult;
import com.shensi.common.core.domain.entity.SysRole;
import com.shensi.common.core.page.TableDataInfo;
import org.springframework.cloud.openfeign.FeignClient;
import org.springframework.cloud.openfeign.SpringQueryMap;
import org.springframework.stereotype.Component;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.ModelAttribute;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestParam;

import java.util.Set;

/**
 * @author: budian
 * @since: 2023/12/6
 */
@FeignClient(
        value = CloudConstant.ADMIN_SERVER,
        fallbackFactory = SysRoleClientFallBack.class)
@Component
public interface SysRoleClient {

    @GetMapping("/system/role/list")
    public TableDataInfo list(@SpringQueryMap SysRole role);


    @GetMapping("/system/role/export")
    public AjaxResult export(@SpringQueryMap SysRole role);

    /**
     * 根据角色编号获取详细信息
     */

    @GetMapping(value = "/system/role/{roleId}")
    public AjaxResult getInfo(@PathVariable("roleId") Long roleId);

    /**
     * 新增角色
     */
    @PostMapping("/system/role")
    public AjaxResult add(@RequestBody SysRole role);

    /**
     * 修改保存角色
     */
    @PutMapping("/system/role")
    public AjaxResult edit(@RequestBody SysRole role);

    /**
     * 修改保存数据权限
     */
    @PutMapping("/system/role/dataScope")
    public AjaxResult dataScope(@RequestBody SysRole role);

    /**
     * 状态修改
     */
    @PutMapping("/system/role/changeStatus")
    public AjaxResult changeStatus(@RequestBody SysRole role);

    /**
     * 删除角色
     */
    @DeleteMapping("/system/role/{roleIds}")
    public AjaxResult remove(@PathVariable("roleIds") Long[] roleIds);

    /**
     * 获取角色选择框列表
     */
    @GetMapping("/system/role/optionselect")
    public AjaxResult optionselect();

    @GetMapping("/system/role/selectRolePermissionByUserId")
    Set<String> selectRolePermissionByUserId(@RequestParam("userId") Long userId);

}
